<h2>Submit Requirment </h2>
<hr>
<div>
<form id="dataform" action="javascript:submit();" autocomplete="off" class="uniForm" style="padding:0.5em 1em 1em 1.5em;">
	<fieldset id="basicID" >
		<?php
			$user_id = $this->user_id;
			$userType = $this->userType;
			if($userType != 'agnt'){ 
		?>
		<div class="ctrlHolder">
          <label for="name"><em>*</em>Name:</label>
          <input name="name" id="name" size="35" maxlength="50" type="text" class="textInput required validatePhrase"/>
          <p class="formHint">Enter your name.</p>
        </div>
		<div class="ctrlHolder">
          <label for="contact"><em>*</em>Contact Number:</label>
          <input name="contact_no" id="contact_no" size="35" maxlength="50" type="text" class="textInput required validateInteger"/>
          <p class="formHint">Please provide your contact number to contact you.</p>
        </div>
        <div class="ctrlHolder">
          <label for="email">Email:</label>
          <input name="email" id="email" size="35" maxlength="50" type="text" class="textInput validateEmail"/>
          <p class="formHint">Please provide your email address if available</p>
        </div>
        <?php
			} 
        ?>
        <div class="ctrlHolder"><label for="category_id">Interested in:</label> <select
			name="category_id" id="category_id" class="selectInput">
			<option value="" selected="selected">Please Select</option>
			<option value="RES">Residential</option>
			<option value="COM">Commercial</option>
			<option value="RRL">Rural</option>
			<option value="IND">Industrial</option>
			</select>
		<p class="formHint">Specify the category yor are interested in.</p>
		</div>

        <div class="ctrlHolder"><label for="looking_for">Looking for:</label>
			<select name="looking_for" id="looking_for" class="selectInput">
			<option value="" selected="selected">Please Select</option>
			<option value="BUY">Buy</option>
			<option value="SALE">Sale</option>
			<option value="RENT">Rent</option>
			</select>
			<p class="formHint">Specify the interest.</p>
		</div>
        <div class="ctrlHolder"><label for="enquiry"><em>*</em>Enquiry</label> <textarea
			name="enquiry" id="summary"
			rows="25" cols="25" class="required"></textarea>
			<p class="formHint">In not more than 2000 words.</p>
		</div>
    </fieldset>
    <div class="buttonHolder">
		<button type="submit" class="secondaryAction">Cancel and go back</button>
		<button type="submit" class="primaryAction">Submit</button>
	</div>
	</form>
	<div id="submitStatus" style="display: none;"
		class="ui-state-highlight ui-corner-all"></div>
    	
</div>

<script>
    var urlPostReq = "<?php echo $this->url(array('controller' => 'requirement', 'action' => 'post'))?>";
    
		    function submit() {
		        $.ajax({
		            url : urlPostReq,
		            data : getValues(),
		            success: function(jStatus){
		                $( "#submitStatus" ).text(jStatus).show( 'blind', '', 'slow', function(){
		                    scroll(this);
		                  	setTimeout(function(){
		                      	window.location.reload();
		                      	},1700);
		                  } );
		              },
		                error: function(response) {
		              	  $('#errorBox').text(response.responseText).parent().show();
		                    console.log(response);
		                    }
		                });
		        }
		    function getValues() {
		        var formData = {oper:'add'}; 
		        $('#dataform :input')
		        .not('button,:input[value^="e.g."]')
		        		.each(function(){
		        			formData[this.name] = this.value;
		            });
					return formData;
				}
    
</script>

<?php
$baseUrl = $this->baseUrl();
$this->headScript()->appendFile($baseUrl.'/plugins/uni-form/js/uni-form-validation.jquery.js');
$this->headLink()->prependStylesheet($baseUrl.'/plugins/uni-form/css/uni-form.css');
$this->headLink()->prependStylesheet($baseUrl.'/plugins/uni-form/css/smooth.uni-form.css');
$this->headLink()->prependStylesheet($baseUrl.'/plugins/uni-form/demos/css/demo.css');
?>